package br.com.android.financas;

import java.util.ArrayList;
import java.util.List;

import org.joda.time.DateTime;

import br.com.android.financas.model.Poupanca;

public class DiaBase implements Comparable<DiaBase> {


	private DateTime data;
	private List<Poupanca> poupancas=new ArrayList<Poupanca>();
	private double valor=0;

	public DateTime getData() {
		return data;
	}
	public void setData(DateTime data) {
		this.data = data;
	}

	public List<Poupanca> getPoupancas() {
		return poupancas;
	}
	public void setPoupancas(List<Poupanca> poupancas) {
		this.poupancas = poupancas;
	}


	public double getValor(){
		if(valor==0){

			valor=0;
			for(Poupanca poupanca:poupancas){
				valor+=poupanca.getValor();
			}

		}
		return valor;
	}
	@Override
	public int hashCode() {
		return 1;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DiaBase other = (DiaBase) obj;
		if (data == null) {
			if (other.data != null)
				return false;
		} else if ( data.getDayOfMonth()!=other.getData().getDayOfMonth() )
			return false;
		return true;
	}
	@Override
	public int compareTo(DiaBase another) {
		if(this.getData().getDayOfMonth()>another.getData().getDayOfMonth() )
			return 1;
		if(this.getData().getDayOfMonth()<another.getData().getDayOfMonth())
			return -1;

		return 0;
	}

}
